package com.qianxx.component.activity.progress.number_progress_bar;

import android.os.Bundle;

import com.qianxx.component.R;
import com.qianxx.component.activity.base.BaseActivity;
import com.qianxx.viewlibrary.progress.numberprogressbar.NumberProgressBar;
import com.qianxx.viewlibrary.progress.numberprogressbar.OnProgressBarListener;

import java.util.Timer;
import java.util.TimerTask;

import butterknife.BindView;
import butterknife.ButterKnife;

public class NumberProgressBarActivity extends BaseActivity {
    @BindView(R.id.number_progress_bar)
    NumberProgressBar number_progress_bar;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_number_progress_bar);
        ButterKnife.bind(this);

        number_progress_bar.setOnProgressBarListener(new OnProgressBarListener() {
            @Override
            public void onProgressChange(int current, int max) {
                if(current == max) {
                    number_progress_bar.setProgress(0);
                }
            }
        });
        timer.schedule(timeTask, 1000, 100);
    }

    Timer timer = new Timer();
    TimerTask timeTask = new TimerTask() {
        @Override
        public void run() {
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    //进度累加
                    number_progress_bar.incrementProgressBy(1);
                }
            });
        }
    };

    @Override
    public String setTitle() {
        return "NumberProgressBar";
    }
}
